function histRegionsCoverage()
% Coverage of histone modification marks grouped by regions (GM06990, chrm 7)
%
%
% SYNTAX: [] = histRegionsCoverage()
%
% See also assembleHistoneDS()
%  
%    DASMiner: DAS library and browser for Matlab.
%    Diogo Veiga, Jan 2009.

load('GM06990chips_chrm7_RegionsView.mat', 'regions');

chipSets = {};
counts = [];

for i=1:size(regions,2)

    res = false;
    
    for j=1:size(chipSets,2)
        if (strcmp(char(chipSets{1,j}),char(regions(i).samples)))
            res = true;
            break;
        end
    end
    if (res) %found chipSet
        counts(j) = counts(j) + 1;
    else %new chipSet
        chipSets{1,end+1} = regions(i).samples;
        counts = [counts 1];
    end
    
end

explode = zeros(size(counts));
[c,offset] = max(counts);
explode(offset) = 1;

h = pie(counts,explode); 
colormap summer

%Label in the graph slice 49%, 31% and slice corresponding to all chips

textObjs = findobj(h,'Type','text');
set(textObjs,'String','');
%oldStr = get(textObjs,{'String'});

%Label in the graph slice 49%
set(textObjs(1),'String',sprintf('49%%\nH3K4me1\nH3K4me2\nH3K4me3\nH3ac\nH4ac'));

%Label in the graph slice 31%
set(textObjs(56),'String',sprintf('31%%\nH3K27me3\nH3K36me3\nH3K4me3\nH3K79me3\nH3K9me3\nCTCF'));
        

